<?php
use \Illuminate\Database\Capsule\Manager;
use \Illuminate\Support\Fluent;
// 调用自动加载文件，添加自动加载文件函数
require __DIR__.'/../vendor/autoload.php';
// 实例化服务容器，注册事件、路由服务提供者
$app = new \Illuminate\Container\Container();
\Illuminate\Container\Container::getInstance($app);
with(new \Illuminate\Events\EventServiceProvider($app))->register();
with(new \Illuminate\Routing\RoutingServiceProvider($app))->register();
// 启动Eloquent ORM模块进行相关配置
$manager = new Manager();
$manager->addConnection(require __DIR__.'/../config/database.php');
$manager->bootEloquent();
$app->instance('config',new Fluent());
// 设置变异文件存储路径、视图模板文件存储路径
$app["config"]['view.compiled'] = __DIR__."\\..\\storage\\framework\\views\\";
$app["config"]['view.paths'] = [__DIR__."\\..\\resources\\views\\"];
with(new \Illuminate\View\ViewServiceProvider($app))->register();
with(new \Illuminate\Filesystem\FilesystemServiceProvider($app))->register();
// 加载路由
require __DIR__."/../app/Http/routes.php";
// 实例化请求并分发处理请求
$request = \Illuminate\Http\Request::createFromGlobals();
$response = $app['router']->dispatch($request);
// 返回请求响应
$response->send();
/**
 * 工作流程
 *  1.自动加载函数添加
 *  2.服务容器实例化与服务注册
 *  3.路由加载
 *  4.请求实例化
 *  5.路由分发
 *  6.响应生成
 *  7.发送
 */